<template>
  <div>
    <MkBillPanel :bill="ctx.xueYeRuKe">
      <template #button>
        <MkButtonQueryHistory @click="listRef.open()" />
        <MkButtonAdd @click="newEntity" :isEdit='ctx.isEdit' />
        <MkButtonSubmit @click="submit" :loading="ctx.loading" :isEdit="ctx.isEdit" />
      </template>
      <template #info>
        <MkForm ref="formRef" :model="ctx.xueYeRuKe" :col="3">
          <MkSelectBasEntity label="接收科室" v-model="ctx.xueYeRuKe.id" disabled />
          <MkSelectUser label="接收人" />
        </MkForm>
      </template>
      <div>
        <MkPanel title="">
          <MkXueYeScanInput />
        </MkPanel>
        <MkPanel title="入科血液信息">
          <MkPatient v-model="ctx.huanZhe" />
          <MkDescription class="mb5">
            <MkDescriptionItem label="发血单">{{ ctx.faXue.id }}</MkDescriptionItem>
            <MkDescriptionItem label="发血人">{{ ctx.faXue.faXueRen }}</MkDescriptionItem>
            <MkDescriptionItem label="发血时间">{{ ctx.faXue.createTime }}</MkDescriptionItem>
            <MkDescriptionItem label="取血人">{{ ctx.faXue.quXueRen }}</MkDescriptionItem>
            <MkDescriptionItem label="输血前体温">{{ ctx.faXue.shuXueQianTiWen }}</MkDescriptionItem>
          </MkDescription>
          <MkTable :data="ctx.mingXiList">
            <MkColumnIndex />
            <MkColumnXueYe />
            <MkColumn prop="shiFouJieShou" label="是否接收" width="80px" />
            <MkColumn prop="jieShouShiJian" label="接收时间" min-width="140px" />
            <MkColumn prop="jieShouKeShi" label="接收科室" min-width="140px" />
            <MkColumn prop="jieShouRen" label="接收人" min-width="140px" />
          </MkTable>
        </MkPanel>
      </div>

    </MkBillPanel>

    <ListPage ref='listRef' @load='loadEntity' />
  </div>
</template>

<script lang='ts' setup name="xueYeRuKe">
import ListPage from './list.vue'
import { TraFaXueOutput } from '/@/api/tra/TraFaXue';
import { TraShenQingHuanZheOutput } from '/@/api/tra/TraShenQing';


const initState = () => ({
  xueYeRuKe: {

  } as BillEntityType,
  huanZhe: {
    huanZheId: '00100010',
    xingMing: '张三',
    xingBie: '男',
    chuShaiABO: 'A',
    chuShaiRhD: '+',
    nianLing: '30',
    bingQu: 'A病区',
    chuangHao: '01',
    jiuZhenLeiXing: '住院'
  } as TraShenQingHuanZheOutput,
  faXue: {} as TraFaXueOutput,
  mingXiList: [],
  isEdit: false,
  loading: false,
})
const ctx = reactive(initState());

const listRef = ref();

const newEntity = () => {
  Object.assign(ctx, initState());
}
const loadEntity = (row) => {

}
const submit = () => {

}
</script>

<style lang='scss' scoped></style>